﻿/******************************************************    
文件名:operate.cs
版权  (c)  2010-11-23 淘渺圈圈工作室
作者:黄媛媛
创建日期:2010-11-23
维护人员:黄媛媛
维护日期:2010-11-23
文件功能描述:金属材料热处理网络学习平台_Movie查询操作
******************************************************/
using System;
using System.Collections.Generic;
using System.Text;

using Mmht.DB;
using System.Data;

namespace Mmht.BT
{
    public class GetMovie
    {
        TableMovieDB tm = new TableMovieDB();
        /// </summary>
        /// Movie查询
        /// 
        /// <param name="i">查询类型</param>
        /// 1查询全部的Movie
        /// 2查询推荐Movie
        /// 3查询点击率最高的100部Movie
        /// <returns>返回datatable</returns>
        /// Writer：黄媛媛
        /// Create Date：2010-12-02
        private DataTable Get_Movie(int i)
        {
            DataTable dt = new DataTable();
            string sql = string.Empty;
            switch (i)
            {
                case 1: sql = "select * from movie "; break;
                case 2: sql = "select * from movie where iscommend =1"; break;
                case 3: sql = "select top 100 * from movie order by viewnum desc"; break;
            }
            operate op = new operate();
            dt = op.Query(sql);
            return dt;
        }

        /// <summary>
        /// 查询全部的Movie文件
        /// </summary>
        /// 
        /// <returns>datatable</returns>
        /// Writer：黄媛媛
        /// Create Date：2010-12-02
        public DataTable Get_All_Movie()
        {
            return Get_Movie(1);
        }

        /// <summary>
        /// 查询全部的Movie文件
        /// </summary>
        /// 
        /// <returns>datatable</returns>
        /// Writer：黄媛媛
        /// Create Date：2010-12-02
        public DataTable Get_Recommended_Movie()
        {
            return Get_Movie(2);
        }

        /// <summary>
        /// 查询点记率最高得Movie文件
        /// </summary>
        /// 
        /// <returns>datatable</returns>
        /// Writer：黄媛媛
        /// Create Date：2010-12-02
        public DataTable Get_CTRtop_Movie(int number)
        {
            return tm.Get_CTRtop_Movie(number);
        }
        public DataRow GetmovieById(int id)
        {
            return tm.GetmovieById(id);
        }
        public bool DelMovie(int id)
        {
            return tm.DelMovie(id);
        }
        public bool UpdateMovie(string name, string author, string remark, int id)
        {
            return tm.UpdateMovie(name, author, remark, id);
        }
        public DataTable GetMoviebyname(string name) 
        {
            return tm.GetMoviebyname(name);
        }
        public bool Recommend( int id) 
        {
            return tm.Recommend(id);
        }
        public bool Unrecommend(int id) 
        {
            return tm.Unrecommend(id);
        }
        public bool ClearViewnum(int id) 
        {
            return tm.ClearViewnum(id);
        }
        public bool ClearAllViewnum() 
        {
            return tm.ClearAllViewnum();
        }

        public void UploadMovie(DataTable dt, int create_by, DateTime create_at)
        {
            if (dt == null || dt.Rows.Count == 0)
            {
                return;
            }
            else
            {
                tm.UploadMovie(dt, create_by, create_at);
            }
        }

        public DataTable UploadMovieInfo(DateTime create_at, int create_by)
        {
            return tm.UploadMovieInfo(create_at, create_by);
        }

        public DataTable SearchMovie(string key)
        {
            return tm.SearchMovie(key);
        }

        public bool AddImage(int id, string imageUrl)
        {
            return tm.AddImage(id, imageUrl);
        }
    }
}
